<%@ page language="java" import="java.util.*,com.gxuwz.medical.domain.chronicinfo.Reducttreat" pageEncoding="utf-8"%>
<%@ include file="/common/base.jsp"%>
<%
 //所在乡镇行政区域编码
 String town=(String)session.getAttribute("agencode");
Institution inst=new Institution();
inst.setAgencode(town);
inst.loadDB();
town=inst.getArea().getAreacode();
 System.out.print("town:"+town);
 AreaDao areaDao =new AreaDao();
 //根据乡镇编码获取所有村
 List<Area> areaList=areaDao.findChildArea(town, 3);
 List<Area> areaGroup=areaDao.findChildArea(town, 4);
%>
<!DOCTYPE html>
<html lang="zh-cn">
<head>
<base href="<%=basePath%>">

<title>慢病报销列表</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport"
	content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta name="renderer" content="webkit">
<link rel="stylesheet" href="css/styles.css">
<link rel="stylesheet" href="css/admin.css">
<script src="js/jquery-1.4.4.min.js"></script>
<script src="js/admin.js"></script>
</head>
<body>
	<form method="post" action="<%=path%>/system/ChronicInfoServlet?m=reductlist" id="listform">
		<div class="panel admin-panel">
			<div class="panel-head">
				<strong class="icon-reorder">慢病报销列表</strong>
			</div>
			<div class="padding border-bottom">
				<ul class="search" style="padding-left:10px;">
				<li><a class="button border-main icon-plus-square-o"
						href="system/ChronicInfoServlet?m=inputreduct"> 申请慢病报销</a></li>
				   <li>所在村:<select id="village" name="village" class="input"
						   style="width:150px; line-height:17px;display:inline-block" 
							onchange="chooseGroup();">
					        <option value="">默认全部</option>
							<% for(Area m:areaList) {%>				
							<option data="<%=m.getParent().getAreaname() %>" value="<%=m.getAreacode()%>"><%=m.getAreaname() %></option>
							<% } %>
						</select>
						所在组：
						<select id="group" name="group" class="input" style="width:150px; line-height:17px;display:inline-block"  >
								<option value="">默认全部</option>
								<% for(Area m:areaGroup) {%>				
							<option data="<%=m.getParent().getAreaname() %>" value="<%=m.getAreacode()%>"><%=m.getAreaname() %></option>
							<% } %>
							</select>
						审核状态:
						<select id="status" name="status" class="input" style="width:150px; line-height:17px;display:inline-block"  >
								<option value="">默认全部</option>
							<option value="0">未审核</option>
							<option value="1">已报销</option>
							<option value="2">审核未通过</option>
							</select>
						</li>
					<li>姓名：</li>
					<li><input type="text" placeholder="请输入姓名" name="keywords"
						class="input"
						style="width:150px; line-height:17px;display:inline-block" />
						 <button class="button border-main icon-search" type="submit"> 搜索</button></li>
						 <li><a class="button border-main icon-plus-square-o"
						href="system/ChronicInfoServlet?m=reductprint">&nbsp;&nbsp;打印已报销 &nbsp;</a></li>
					
				</ul>
			</div>
			<table class="table table-hover text-center">
				<tr><th >序号</th>
					<th >&nbsp;</th>
					<th>农合证号</th>
					<th>姓名</th>
					<th>疾病编号</th>
					<th>疾病名称</th>
					<th>医院发票号</th>
					<th>就诊时间</th>
					<th>报销金额</th>
					<th>操作</th>
				</tr>
				<%
					String pageNo = request.getParameter("pageNo");
				String sqll="select * from t_person,t_reducttreat,t_chronicinfo,t_family  where t_reducttreat.chronicInfoId=t_chronicinfo.id and t_chronicinfo.perscode=t_person.perscode and t_person.famicode=t_family.famicode ";
				int key=0;
				Object[] params =new Object[4];
				String village=request.getParameter("village");
				if(village!=null&&!village.equals("")) {
					sqll+="and t_family.village=? ";
					params[key]=village;
					key++;
					System.out.println("village="+village);
				}
				String group=request.getParameter("group");
				if(group!=null&&!group.equals("")) {
					sqll+="and t_family.groupNo=? ";
					params[key]=group;
					key++;
					System.out.println("group="+group);
				}
				String keywords=request.getParameter("keywords");
				if(keywords!=null&&!keywords.equals("")) {
					params[key]=keywords;
					sqll+="and t_person.persname=? ";
					key++;
					System.out.println("persname="+keywords);
				}
				String status=request.getParameter("status");
				if(status!=null&&!status.equals("")) {
					params[key]=status;
					sqll+="and t_reducttreat.reductstatus=?";
					key++;
					System.out.println("status="+status);
				}
					int p = pageNo == null ? 1 : Integer.parseInt(pageNo);
					ReducttreatDao dao = new ReducttreatDao();
					String sql = "select * from t_reducttreat where 1=1 ";
					Page pageBean=null;
					System.out.println("key="+key+"      fasd     ");
					if(key>0){
						sql=sqll;
						List<Reducttreat> list=dao.queryOjects(sql,params);
						pageBean=new Page(1,1,list);
					}
					else{
						pageBean = dao.queryOjectsByPage(sql, params, p,
							Constant.ROW);
					}
				%>
				<%
					for (int i = 0; i < pageBean.getDatas().size(); i++) {

						Reducttreat  model= (Reducttreat) pageBean.getDatas().get(i);
						Integer reductstatus=model.getReductstatus();
				%>
				<tr>
				<td><%=(i+1) %></td>
					<td><input type="checkbox" name="ids"
						value="<%=model.getId()%>" /></td>
					<td ><%=model.getChronicInfo().getPerson().getPerscode()%></td>
					<td><%=model.getChronicInfo().getPerson().getPersname()%></td>
					<td><%=model.getChronicInfo().getChronicdis().getIllcode() %></td>
					<td><%=model.getChronicInfo().getChronicdis().getIllname()%></td>
					<td><%=model.getHosId() %></td>
					<td><%=model.getTreattime()%></td>
					<td><%=model.getFreemoney()%></td>
					<td><div class="button-group">
					        <%
					        if(reductstatus==0){
					        %>
							<a class="button border-main"
								href="<%=path%>/system/ChronicInfoServlet?m=givemoney&id=<%=model.getId()%>&flag=1"><span
								class="icon-edit"></span> 确认汇款</a> <a class="button border-red"
								href="<%=path%>/system/ChronicInfoServlet?m=givemoney&id=<%=model.getId()%>&flag=2"><span
								class="icon-trash-o"></span> 取消汇款</a>
								<%
					        }
					        else if(reductstatus==1){
								%>
								 <input type="text" readonly="readonly" class="button border-main" value="已报销"
								> 
								<%
					        }
					        else {
								%>
								<a class="button border-main"
								href="<%=path%>/system/ChronicInfoServlet?m=delreduct&id=<%=model.getId()%>"><span
								class="icon-edit"></span> 未通过审核，删除</a>
								<%
					        }
								%>
						</div></td>
				</tr>
				<%
					}
				%>
			</table>
			<div class="pagelist">
				<%
					if (pageBean.hasPre()&&key==0) {
				%>
				<a
					href="<%=path%>/system/ChronicInfoServlet?m=reductlist&pageNo=<%=pageBean.prePage()%>">上一页</a>
				<%
					} else {
				%>
				<a href="javascript:void(0)">上一页</a>
				<%
					}
				%>
				<%
					List<Integer> linkNums = pageBean.linkLumbers();
					for (int num : linkNums) {
					if (pageBean.isCurrent(num)) {
				%>
				<span class="current"><%=num%></span>
				<%
					} else {
				%>
				<a href="<%=path%>/system/ChronicInfoServlet?m=reductlist&pageNo=<%=num%>"><%=num%></a>
				<%
					}
					}
				%>
				<%
					if (pageBean.hasNext()&&key==0) {
				%>
				<a
					href="<%=path%>/system/ChronicInfoServlet?m=reductlist&pageNo=<%=pageBean.lastPage()%>">下一页</a>
				<%
					} else {
				%>
				<a href="javascript:void(0)">下一页</a>
				<%
					}
				if(key==0){
				%>
				<a
					href="<%=path%>/system/ChronicInfoServlet?m=reductlist&pageNo=<%=pageBean.getPages()%>">尾页</a>
					<%
				}
				else {
					%>
					<a href="javascript:void(0)">尾页</a>
					<%
					}
					%>
			</div>
		</div>
	</form>

</body>
</html>
